package com.framework.modules.finance.service.impl;

import cn.hutool.core.date.DateUtil;
import org.springframework.stereotype.Service;

import java.util.Date;
import java.util.Map;
import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.baomidou.mybatisplus.plugins.Page;
import com.baomidou.mybatisplus.service.impl.ServiceImpl;
import com.framework.common.utils.PageUtils;
import com.framework.common.utils.Query;

import com.framework.modules.finance.dao.PlatformIncomeDetailDao;
import com.framework.modules.finance.entity.PlatformIncomeDetailEntity;
import com.framework.modules.finance.service.PlatformIncomeDetailService;


@Service("platformIncomeDetailService")
public class PlatformIncomeDetailServiceImpl extends ServiceImpl<PlatformIncomeDetailDao, PlatformIncomeDetailEntity> implements PlatformIncomeDetailService {

    @Override
    public PageUtils queryPage(Map<String, Object> params) {
        EntityWrapper wrapper=new EntityWrapper<PlatformIncomeDetailEntity>();
        if(params.containsKey("adddate")){
            int adddate=Integer.parseInt(params.get("adddate").toString());
            Date date=new Date(adddate*1000l);
            //一天的开始，结果：2017-03-01 00:00:00
            long beginOfTime = DateUtil.beginOfDay(date).getTime()/1000;
            //一天的结束，结果：2017-03-01 23:59:59
            long endOfDay = DateUtil.endOfDay(date).getTime()/1000;
            wrapper.between("adddate",beginOfTime,endOfDay);
        }
        Page<PlatformIncomeDetailEntity> page = this.selectPage(
                new Query<PlatformIncomeDetailEntity>(params).getPage(),
                wrapper.orderBy("adddate",false)
        );

        return new PageUtils(page);
    }

}
